<?php

/**
 * EmsStatisticsVisits form base class.
 *
 * @method EmsStatisticsVisits getObject() Returns the current form's model object
 *
 * @package    ems1
 * @subpackage form
 * @author     Jacobo Martínez
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseEmsStatisticsVisitsForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                => new sfWidgetFormInputHidden(),
      'session'           => new sfWidgetFormInputText(),
      'portal_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Portal'), 'add_empty' => false)),
      'section_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Section'), 'add_empty' => true)),
      'content_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Content'), 'add_empty' => true)),
      'is_external'       => new sfWidgetFormInputCheckbox(),
      'device_brand_name' => new sfWidgetFormInputText(),
      'device_model_name' => new sfWidgetFormInputText(),
      'device_user_agent' => new sfWidgetFormInputText(),
      'created_at'        => new sfWidgetFormDateTime(),
      'updated_at'        => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'session'           => new sfValidatorString(array('max_length' => 100)),
      'portal_id'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Portal'))),
      'section_id'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Section'), 'required' => false)),
      'content_id'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Content'), 'required' => false)),
      'is_external'       => new sfValidatorBoolean(array('required' => false)),
      'device_brand_name' => new sfValidatorString(array('max_length' => 100)),
      'device_model_name' => new sfValidatorString(array('max_length' => 100)),
      'device_user_agent' => new sfValidatorString(array('max_length' => 255)),
      'created_at'        => new sfValidatorDateTime(),
      'updated_at'        => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('ems_statistics_visits[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'EmsStatisticsVisits';
  }

}
